﻿#region
using System.Collections.Generic;
using YoutubeExtractor;

#endregion

namespace Y2M2
{
    internal class ClipInfo
    {
        public ClipInfo(VideoInfo videoInfo, Clip clip)
        {
            Resolution = videoInfo.Resolution;
            VideoType = videoInfo.VideoType;

            Clip = clip;
            Clip.DownloadUrl = videoInfo.DownloadUrl;
            Clip.VideoInfo = videoInfo;
        }

        public Clip Clip { get; private set; }

        public VideoInfo VideoInfo { get; private set; }

        public int Resolution { get; private set; }

        public VideoType VideoType { get; private set; }
    }

    internal class ClipInfoComparer : IComparer<ClipInfo>
    {
        public int Compare(ClipInfo x, ClipInfo y)
        {
            if (x.Resolution != y.Resolution)
                return x.Resolution.CompareTo(y.Resolution) * -1;

            if (x.VideoType == y.VideoType)
                return 0;

            if (x.VideoType == VideoType.Mp4)
                return -1;
            else if (y.VideoType == VideoType.Mp4)
                return 1;
            else
                return 0;
        }
    }
}